#include "field.h"
#include <stdio.h>

int main()
{
	int row, column;
	char ch;

	new_game();

	while(true)
	{
		draw();
		printf("Enter ROW?");
		scanf("%d", &row);
		fflush(stdin);

		printf("Enter COLUMN?");
		scanf("%d", &column);
		fflush(stdin);
		
		printf("Enter X or O?");
		scanf("%c", &ch);
		fflush(stdin);

		if( ch == 'X' || ch == 'x' )
			ch = CROSS;
		else if( ch == 'O' || ch == 'o' )
			ch = ZERO;

		put( row, column, ch );

        char res = check_state();
        if( res == ZERO_WIN )
        {
            printf( "ZERO_WIN\n" );
            break;
        }
        else if( res == CROSS_WIN )
        {
            printf( "CROSS_WIN\n" );
            break;
        }
        else if( res == TIE )            
        {
            printf( "TIE\n" );
            break;
        }
    }
    draw();
	return 0;
}
